package cc.vv.btpartyjob.partyservice.activity

import cc.vv.baselibrary.bean.base.BaseResponseObj
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.partyservice.binder.ServiceBaseBinder
import cc.vv.btpartyjob.partyservice.delegate.VolunteerPersonDetailActivityDelegate
import cc.vv.btpartyjob.partyservice.module.resp.VolunteerInfoResponseObj
import cc.vv.btpartyjob.partyservice.server.DataPartyServer
import cc.vv.mvp.activity.BaseActivityMVP
import cc.vv.mvp.binder.BaseDataBinder

/**
 * 志愿者详情
 * Created by Chen.qi on 2018/10/29.
 */
class VolunteerPersonDetailActivity : BaseActivityMVP<VolunteerPersonDetailActivityDelegate>() {


    override fun initData() {
        viewDelegate?.setTopBarTitle("志愿者")
        var id: String? = null
        try {
            id = intent?.getStringExtra("id")
        } catch (e: Exception) {
        }
        viewDelegate?.setImageBg()
        DataPartyServer.getVolunteerInfo(id, true)
    }

    override fun bindEvenListener() {
        viewDelegate?.setTitleBackBtnOnClick(object : BaseTopBarView.EventInterface {
            //返回
            override fun leftOnClick() {
                finish()
            }

            override fun leftCloseClick() {}
            override fun rightOnClick() {
            }
        })


    }

    override fun getDelegateClass(): Class<VolunteerPersonDetailActivityDelegate> {
        return VolunteerPersonDetailActivityDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return ServiceBaseBinder()
    }

    override fun getData(obj: BaseResponseObj<*>?) {
        super.getData(obj)
        when (obj) {
            is VolunteerInfoResponseObj -> {
                val data = obj.data
                viewDelegate?.setVolunteerHead(data?.faceUrl)
                viewDelegate?.setVolunteerName(data?.name)
                viewDelegate?.setVolunteerType(data?.volunteerType)
                viewDelegate?.setSexIcon(data?.sex)
                viewDelegate?.setVolunteerAge(data?.age)
                viewDelegate?.setVolunteerZhiYe(data?.career)
                viewDelegate?.setVolunteerTechang(data?.specialty)
                viewDelegate?.setVolunteerPhone(data?.mobile)
                viewDelegate?.setVolunteerDiQu(data?.street, data.community, data.grid)
                viewDelegate?.setVolunteerZyTime(data?.volunteerTime)
                viewDelegate?.setVolunteerRemark(data?.remarks)
            }
        }
    }
}